/*package com.lwlk.zdk.datasource;

import com.baomidou.mybatisplus.extension.spring.MybatisSqlSessionFactoryBean;
import org.apache.ibatis.session.SqlSessionFactory;
import org.mybatis.spring.SqlSessionFactoryBean;
import org.mybatis.spring.SqlSessionTemplate;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.jdbc.DataSourceBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
import org.springframework.jdbc.datasource.DataSourceTransactionManager;

import javax.sql.DataSource;
import java.io.IOException;


@Configuration//注解到spring容器中
@MapperScan(basePackages = "com.lwlk.zdk.dataMapper",sqlSessionFactoryRef = "data2SqlSessionFactory")
public class MasterDbConfig {

*//**
     * 返回data1数据库的数据源
     * @return*//*


    @Bean(name="dataSource")
    @ConfigurationProperties(prefix = "spring.datasource.druid.slave")
    public DataSource dataSource(){
        return DataSourceBuilder.create().build();
    }


*//**
     * 返回data1数据库的会话工厂
     * @param ds
     * @return
     * @throws Exception*//*



    @Bean(name = "data2SqlSessionFactory")
    public SqlSessionFactory sqlSessionFactory(@Qualifier("dataSource") DataSource ds) throws Exception{
        //SqlSessionFactoryBean bean = new SqlSessionFactoryBean();
        //bean.setDataSource(ds);
        SqlSessionFactoryBean bean = new SqlSessionFactoryBean();
        org.apache.ibatis.session.Configuration configuration = new org.apache.ibatis.session.Configuration();
        configuration.setCallSettersOnNulls(true);
        bean.setConfiguration(configuration);
        bean.setDataSource(ds);
        return bean.getObject();
    }


*//**
     * 返回data1数据库的会话模板
     * @param sessionFactory
     * @return
     * @throws Exception*//*



    @Bean(name = "data2SqlSessionTemplate")
    public SqlSessionTemplate sqlSessionTemplate(@Qualifier("data2SqlSessionFactory") SqlSessionFactory sessionFactory) throws  Exception{
        return  new SqlSessionTemplate(sessionFactory);
    }


*//**
     * 返回data1数据库的事务
     * @param ds
     * @return*//*



    @Bean(name = "data2TransactionManager")
    public DataSourceTransactionManager transactionManager( DataSource ds) throws IOException {
        MybatisSqlSessionFactoryBean sqlSessionFactory = new MybatisSqlSessionFactoryBean();
        sqlSessionFactory.setDataSource(ds);
        sqlSessionFactory.setMapperLocations(new PathMatchingResourcePatternResolver().
                getResources("classpath*:com/lwlk/zdk/dataMapper/*.xml"));
        return new DataSourceTransactionManager(ds);
    }
}*/

